package common;

import java.io.Serializable;

public class Tile implements Serializable{
    
    /**
     * 
     */
    private static final long serialVersionUID = 1375258057780221438L;
    private Coordinate coordinate;
    private enumCompany company = null;
    private boolean onBoard = false;
    private boolean isBetweenSafeCompanies = false;
    
    
    @SuppressWarnings("unused")
    private Tile() {}
    
    public Tile(Coordinate coor) {
        this.coordinate = coor;
    }
    
    public String getInitial()
    {   
    	if (!onBoard)
    	{
    		return " ";
    	}
    	
    	if (isBetweenSafeCompanies)
    	{
    		return "*";
    	}
    	
    	if (onBoard && company == null)
    		return "#";
    	
    	
    	switch (company)
    	{
	    	case SACKSON:
	    		return "S";
	    	case ZETA:
	    		return "Z";
	    	case AMERICA:
	    		return "A";
	    	case HYDRA:
	    		return "H";
	    	case FUSION:
	    		return "F";
	    	case PHOENIX:
	    		return "P";
	    	case QUANTUM:
	    		return "Q";	    		
	    	default:
	    		return " ";
    	}
    }
       
    public enumCompany getCompany() {
        return company;
    }

    public void setCompany(enumCompany company) {
        this.company = company;
    }
    
    public Coordinate getLocation() {
        return coordinate;
    }
    
    public boolean isOnBoard() {
        return onBoard;
    }
    
    public void setOnBoard()
    {
        onBoard = true;
    }
    
    public void setIsBetweenSafeCompanies()
    {
    	isBetweenSafeCompanies = true;
    }
    
    public String toString(){
    	int x = coordinate.getX();
    	int y = coordinate.getY()+1;
    	switch (x) { 
    	case 0:
    		return "A" + y;
    	case 1:
    		return "B" + y;
    	case 2:
        	return "C" + y;
        case 3:
        	return "D" + y;
        case 4:
    		return "E" + y;
    	case 5:
    		return "F" + y;
    	case 6:
        	return "G" + y;
        case 7:
        	return "H" + y;
        case 8:
        	return "I" + y;
    	default:
    		return "";
    	}
    }
}
